package com.thales.sentinel.model;

/**
 * 许可证相关异常类
 * 用于处理许可证验证失败、过期、用户数量超限等情况
 */
public class LicenseException extends RuntimeException {
    
    private final LicenseErrorType errorType;
    
    public LicenseException(LicenseErrorType errorType, String message) {
        super(message);
        this.errorType = errorType;
    }
    
    public LicenseException(LicenseErrorType errorType, String message, Throwable cause) {
        super(message, cause);
        this.errorType = errorType;
    }
    
    public LicenseErrorType getErrorType() {
        return errorType;
    }
    
    /**
     * 许可证错误类型枚举
     */
    public enum LicenseErrorType {
        LICENSE_EXPIRED("许可证已过期"),
        MAX_USERS_EXCEEDED("用户数量超过许可证限制"),
        FEATURE_NOT_LICENSED("功能未授权"),
        LICENSE_READ_ERROR("读取许可证信息失败"),
        LICENSE_PARSE_ERROR("解析许可证信息失败"),
        HASP_LOGIN_FAILED("加密狗登录失败"),
        HASP_NOT_FOUND("未找到加密狗");
        
        private final String description;
        
        LicenseErrorType(String description) {
            this.description = description;
        }
        
        public String getDescription() {
            return description;
        }
    }
}